<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ allCount }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: 'all' === isSel }"
          href="javascript:;"
          @click="typeFn('all')"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: 'no' === isSel }"
          @click="typeFn('no')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: 'yes' === isSel }"
          @click="typeFn('yes')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="delFn">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ['arr'],//传入给父
  data () {
    return {
      isSel: 'all'//定义高亮
    }
  },
  methods: {
    // 高亮切换筛选条件--点击事件
    typeFn (Stringtype) {
      this.isSel = Stringtype//吧点击的参数赋值等于上面定义的高亮的变量
      this.$emit('typeEV', this.isSel)
    },
    // 清除已完成
    delFn () {
      this.$emit('delEV')
    }
  },
  // 总数量的计算属性
  computed: {
    allCount () {
      return this.arr.length

    }
  }
}
</script>